package com.liu.algorithm03;

import java.util.Scanner;

public class SearchDiffString {
    // 找到给定字符串中的不同字符
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str1 = scan.next();
        String str2 = scan.next();
        diffValue(str1, str2);
        System.out.println("----------------------------------");
        diffXorValue(str1,str2);
    }
    // 方法一
    private static void diffValue(String str1, String str2) {
        int sum1 = 0;
        int sum2 = 0;
        char[] chars1 = str1.toCharArray();
        char[] chars2 = str2.toCharArray();
        for (int i = 0; i < chars1.length; i++) {
            sum1 += chars1[i];
        }
        for (int i = 0; i < chars2.length; i++) {
            sum2 += chars2[i];
        }
        int abs = Math.abs(sum1 - sum2);
        System.out.println((char)abs);
    }
    // 方法2：使用异或
    public static void diffXorValue(String str1,String str2){
        int temp = 0;
        for (int i = 0; i < str1.length(); i++) {
            System.out.println(str1.charAt(i));
            temp ^= str1.charAt(i);
        }
        for (int i = 0; i < str2.length(); i++) {
            System.out.println(str2.charAt(i));
            temp ^= str2.charAt(i);
        }
        System.out.println((char) temp);
    }
}
